package com.matrix.draft.juc.day8;

import java.util.Arrays;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet;

/**
 * CopyOnWriteArrayList线程安全列表
 */
public class TestCopyOnWriteArrayList {
    public static void main(String[] args) {
        CopyOnWriteArrayList<String> list = new CopyOnWriteArrayList<>();
        list.add("Java");
        list.add("Java");
        list.add("Java");

        CopyOnWriteArraySet<String> set = new CopyOnWriteArraySet<>();
        set.add("Java");
        set.add("Golang");
        set.add("Python");


        System.out.println(set.size());
        System.out.println(Arrays.toString(set.toArray()));

        set.removeIf(s->"Java".equals(s));

        System.out.println(set.size());
        System.out.println(Arrays.toString(set.toArray()));


//        System.out.println(list.size());
//        System.out.println(Arrays.toString(list.toArray()));
//
//        list.removeIf(s->"Java".equals(s));
//
//        System.out.println(list.size());
//        System.out.println(Arrays.toString(list.toArray()));
    }
}
